<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let flag = true
    let loginList = [ 
  {userName: 'admin', password: 'admin321'},
  {userName: 'zhangsan', password: 'zs321'},
  {userName: 'lisi', password: 'ls321'},
  {userName: 'yyqx', password: 'yyqx321'}
]
    while(flag){
     

let uname = prompt('请输入用户名')
    let password02 = prompt('请输入密码')
   let userInfo = {
  token1: {
    city: '杭州',
    money: '1000w',
    sex: '女',
    userName: 'admin',
    password: 'admin321'
  },
  token2: {
    city: '北京',
    money: '1100w',
    sex: '女',
    userName: 'zhangsan',
    password: 'zs321'
  },
  token3: {
    city: '北京',
    money: '800w',
    sex: '男',
    userName: 'lisi', 
    password: 'ls321'
  },
  token4: {
    city: '天津',
    money: '600w',
    sex: '男',
    userName: 'yyqx',
    password: 'yyqx321'
  }
}
let to = 'token'
for(let i = 0; i <  loginList.length; i++){
 
  
  if(loginList[i].userName === uname && loginList[i].password === password02){
 
   to += Math.floor(Math.random()*4) + 1
for(let k in userInfo){
  if(k === to){
 
  alert(`
  city:${userInfo[k].city}
  money:${userInfo[k].money}
  sex:${userInfo[k].  sex}
  userName:${userInfo[k]. userName}
  password:${userInfo[k]. password}
  `)
}
}

flag = false
  }
}
  if(!flag){
    break
  }

  let num = +prompt(`登入不成功请输入以下数字
1 注册
2 退出
`)
if(num === 1){
   let uname00 = prompt('请输入用户名')
    let password00 = prompt('请输入密码')
   
  loginList.push({userName: uname00,  password: password00})
 
    alert('您已经注册成功快去登入吧')
   continue
}else{
 break
}
}
 </script>
</body>
</html>